<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="zh">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>入库管理</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.7 -->
    <link rel="stylesheet" href="../../bower_components/bootstrap/dist/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="../../bower_components/font-awesome/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="../../bower_components/Ionicons/css/ionicons.min.css">
    <!-- DataTables -->
    <link rel="stylesheet" href="../../bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="../../dist/css/AdminLTE.min.css">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="../../dist/css/skins/_all-skins.min.css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

    <!-- Google Font -->
    <link rel="stylesheet"
          href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

    <header class="main-header">
        <!-- Logo -->
        <a href="#" class="logo">
            <span class="logo-mini"><b>A</b>P</span>
            <span class="logo-lg"><b>Admin</b>Page</span>
        </a>
        <nav class="navbar navbar-static-top">
            <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </a>

            <div class="navbar-custom-menu">
                <ul class="nav navbar-nav">
                    <!-- Notifications: style can be found in dropdown.less -->
                    <li class="dropdown notifications-menu">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                            <i class="fa fa-bell-o"></i>
                            <span class="label label-warning" id="warning"
                                  th:text="${session.warningMerches.size()}"></span>
                        </a>
                        <ul class="dropdown-menu ">
                            <li class="header" th:text="${session.warningMerches.size()}+'条商品库存数量达到警戒线'"></li>
                            <li>
                                <!-- inner menu: contains the actual data -->
                                <ul class="menu" th:each="m:${session.warningMerches}">
                                    <li>
                                        <a href="#">
                                            <i class="fa fa-warning text-yellow"></i>
                                            <span th:text="${m.getMerchName()}"></span>
                                        </a>
                                    </li>
                                </ul>
                            </li>
                            <li class="footer"><a href="#">View all</a></li>
                        </ul>
                    </li>

                    <!-- User Account: style can be found in dropdown.less -->
                    <li class="dropdown user user-menu">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                            <span class="hidden-xs">Admin</span>
                        </a>
                    </li>
                </ul>
            </div>
        </nav>
    </header>
    <!-- Left side column. contains the logo and sidebar -->
    <aside class="main-sidebar">
        <!-- sidebar: style can be found in sidebar.less -->
        <section class="sidebar">
            <!-- sidebar menu: : style can be found in sidebar.less -->
            <ul class="sidebar-menu" data-widget="tree">
                <li class="header">MAIN NAVIGATION</li>
                <li>
                    <a href="/">
                        <i class="fa fa-pie-chart"></i> <span>数据统计</span>
                    </a>
                </li>
                <li class="treeview">
                    <a href="#">
                        <i class="glyphicon glyphicon-gift"></i> <span>商品管理</span>
                        <span class="pull-right-container">
                <i class="fa fa-angle-left pull-right"></i>
              </span>
                    </a>
                    <ul class="treeview-menu">
                        <li><a href="/merch/listMerch"><i class="fa fa-circle-o"></i>商品列表</a></li>
                        <li><a href="/merch/addMerch"><i class="fa fa-circle-o"></i>添加商品</a></li>
                    </ul>
                </li>

                <li class="treeview">
                    <a href="#">
                        <i class="glyphicon glyphicon-send"></i>
                        <span>供应商管理</span>
                        <span class="pull-right-container">
                <i class="fa fa-angle-left pull-right"></i>
              </span>
                    </a>
                    <ul class="treeview-menu">
                        <li><a href="/provider/list"><i class="fa fa-circle-o"></i>供应商列表</a></li>
                        <li><a href="/provider/addProvider"><i class="fa fa-circle-o"></i>添加供应商</a></li>
                    </ul>
                </li>
                <li class="treeview active">
                    <a href="#">
                        <i class="fa fa-laptop"></i>
                        <span>入库管理</span>
                        <span class="pull-right-container">
                            <i class="fa fa-angle-left pull-right"></i>
                        </span>
                    </a>
                    <ul class="treeview-menu">
                        <li><a href="/instock/list"><i class="fa fa-circle-o"></i>入库记录</a></li>
                        <li class="active"><a href="/instock/add"><i class="fa fa-circle-o"></i>添加记录</a></li>
                    </ul>
                </li>
                <li class="treeview">
                    <a href="#">
                        <i class="glyphicon glyphicon-shopping-cart"></i> <span>销售管理</span>
                        <span class="pull-right-container">
                <i class="fa fa-angle-left pull-right"></i>
              </span>
                    </a>
                    <ul class="treeview-menu">
                        <li><a href="/sale/getAll"><i class="fa fa-circle-o"></i>订单列表</a></li>
                        <li><a href="/sale/adds"><i class="fa fa-circle-o"></i>添加订单</a></li>
                    </ul>
                </li>
                <li class="treeview">
                    <a href="#">
                        <i class="glyphicon glyphicon-user"></i> <span>会员管理</span>
                        <span class="pull-right-container">
                <i class="fa fa-angle-left pull-right"></i>
              </span>
                    </a>
                    <ul class="treeview-menu">
                        <li><a href="/member/list"><i class="fa fa-circle-o"></i>会员列表</a></li>
                        <li><a href="/member/add"><i class="fa fa-circle-o"></i>添加会员</a></li>
                    </ul>
                </li>
                <li class="treeview">
                    <a href="#">
                        <i class="fa fa-calendar"></i> <span>员工管理</span>
                        <span class="pull-right-container">
                <i class="fa fa-angle-left pull-right"></i>
              </span>
                    </a>
                    <ul class="treeview-menu">
                        <li><a href="/staff/listStaff"><i class="fa fa-circle-o"></i>员工列表</a></li>
                        <li><a href="/staff/addStaff"><i class="fa fa-circle-o"></i>添加员工</a></li>
                    </ul>
                </li>
            </ul>
        </section>
        <!-- /.sidebar -->
    </aside>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>入库记录</h1>
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">
                        <div class="box-header">
                        </div>
                        <form role="form" id="addForm">
                            <div class="box-body">
                                <div class="form-group">
                                    <label>商品</label>
                                    <select class="form-control select2 select2-hidden-accessible" name="merchId">
                                        <option value="0">请选择商品</option>
                                        <option th:each="merch:${merches}" th:text="${merch.getMerchName()}"
                                                th:value="${merch.getMerchId()}"></option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label>供应商</label>
                                    <select class="form-control select2 select2-hidden-accessible" name="providerId">
                                        <option value="0">请选择供应商</option>
                                        <option th:each="provider:${providers}" th:text="${provider.getProviderName()}"
                                                th:value="${provider.getProviderId()}"></option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label class="control-label">商品数量</label>
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-check"></i></span>
                                        <input type="text" class="form-control" id="number" name="number">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label">商品单价</label>
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-rmb"></i></span>
                                        <input type="text" class="form-control" id="price" name="price">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label">商品总价</label>
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-rmb"></i></span>
                                        <input type="text" class="form-control" id="totalPrice" name="totalPrice"
                                               readonly>
                                    </div>
                                </div>
                            </div>
                            <div class="box-footer">
                                <button type="button" class="btn btn-primary" id="addInstock">提交记录</button>
                            </div>
                        </form>


                    </div>
                </div>
            </div>
        </section>
    </div>
</div>
<!-- ./wrapper -->

<!-- jQuery 3 -->
<script src="../../bower_components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="../../bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- DataTables -->
<script src="../../bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
<script src="../../bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
<!-- SlimScroll -->
<script src="../../bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="../../bower_components/fastclick/lib/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="../../dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="../../dist/js/demo.js"></script>
<!-- page script -->
<script>
    $(document).ready(function () {
        $("#addInstock").click(function () {
            var obj = new Object();
            obj.merch = {"merchId": $("select[name='merchId']").val()};
            obj.provider = {"providerId": $("select[name='providerId']").val()};
            obj.number = $('#number').val();
            obj.price = $('#price').val();
            obj.totalPrice = $('#totalPrice').val();
            var data = JSON.stringify(obj);
            $.ajax({
                url: "/instock/add",
                contentType: 'application/json',
                dataType: "json",
                type: "post",
                data: data,
                success: function (data) {
                    alert(data.msg);
                    window.location.reload();
                },
                error: function (data) {
                    alert("error");
                }
            });
        });

        $('#number').blur(function () {
            var number = $('#number').val();
            var price = $('#price').val();
            if (number != "" && price != "")
                $('#totalPrice').val(number * price);
        });

        $('#price').blur(function () {
            var number = $('#number').val();
            var price = $('#price').val();
            if (number != "" && price != "")
                $('#totalPrice').val(number * price);
        })
    });
</script>
</body>
</html>
